home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / src / portable / beep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  3.8 KB  |  138 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. #define    CURSES_LIBRARY    1
  20. #include <curses.h>
  21. #ifdef UNIX
  22. #include <defs.h>
  23. #include <term.h>
  24. #endif
  25.  
  26. /* undefine any macros for functions defined in this module */
  27. #undef    beep
  28. #undef    flash
  29.  
  30. /* undefine any macros for functions called by this module if in debug mode */
  31. #ifdef PDCDEBUG
  32. #  undef    delay_output
  33. #  undef    wrefresh
  34. #endif
  35.  
  36. #ifdef PDCDEBUG
  37. char *rcsid_beep  = "$Id$";
  38. #endif
  39.  
  40. /*man-start*********************************************************************
  41.  
  42.   Name:                                                          beep
  43.  
  44.   Synopsis:
  45.       int beep(void);
  46.       int flash(void);
  47.  
  48.   X/Open Description:
  49.      These routines are used to signal the terminal user.  The beep()
  50.      function will sound the audible bell on the terminal, if possible
  51.      and if not, will flash the screen (visible bell), if possible.
  52.      The flash() function will flash the screen, and if that is not
  53.      possible, will sound the audible signal.  If neither signal is
  54.      possible, nothing will happen.  Nearly all terminals have an
  55.      audible signal (bell or beep), but only some can flash the screen.
  56.  
  57.   X/Open Return Value:
  58.      These functions return OK on success and ERR on error.
  59.  
  60.   X/Open Errors:
  61.      No errors are defined for these functions.
  62.  
  63.   Portability                             X/Open    BSD    SYS V
  64.                                           Dec '88
  65.       beep                                  Y        Y       Y
  66.       flash                                 Y        Y       Y
  67.  
  68. **man-end**********************************************************************/
  69.  
  70. /***********************************************************************/
  71. int    beep(void)
  72. /***********************************************************************/
  73. {
  74. #ifdef PDCDEBUG
  75.     if (trace_on) PDC_debug("beep() - called\n");
  76. #endif
  77.  
  78.     if (!_cursvar.audible)
  79.     {
  80.         flash();
  81.         return( ERR );        /* We try to flash instead...*/
  82.     }
  83.  
  84. #ifdef UNIX
  85.     if (bell != NULL)
  86.         putp(bell);
  87. #endif
  88.  
  89. #if defined (XCURSES)
  90.     XCurses_instruct(CURSES_BELL);
  91. #endif
  92.  
  93. #if defined(DOS) 
  94.     PDC_putctty( (chtype)'\007', 0 );
  95. #endif
  96.  
  97. #if defined(OS2)
  98. #   if defined(EMXVIDEO)
  99.     putchar('\007');
  100. #   else
  101.     DosBeep( 1380, 100 );
  102. #   endif
  103. #endif
  104.  
  105.     return( OK );
  106. }
  107. /***********************************************************************/
  108. int    flash(void)
  109. /***********************************************************************/
  110. {
  111.     extern unsigned char atrtab[MAX_ATRTAB];
  112.     int    i;
  113.  
  114. #ifdef PDCDEBUG
  115.     if (trace_on) PDC_debug("flash() - called\n");
  116. #endif
  117.  
  118. #ifdef UNIX
  119.     if (flash_screen != NULL)
  120.         putp(flash_screen);
  121.     return(OK);
  122. #endif
  123.  
  124. #if defined(DOS) || defined(OS2)
  125.     PDC_scroll(0, 0, LINES - 1, COLS - 1, 0, A_NORMAL);
  126.     delay_output( 50 );
  127.     PDC_scroll(0, 0, LINES - 1, COLS - 1, 0, A_REVERSE);
  128.     wrefresh(curscr);
  129.     return( OK );
  130. #endif
  131.  
  132. #if defined(XCURSES)
  133.     XCurses_instruct(CURSES_FLASH);
  134.     return(OK);
  135. #endif
  136. }
  137.